﻿using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using DynamicData;
using FluentAvalonia.UI.Controls;

namespace DevHub.WindowsApp.ViewModels.Pages.Help;

public class IconViewModel : PageModelBase
{
    public IconViewModel()
    {
        Symbols = new ObservableCollection<Symbol>();
        Init();
    }

    private async void Init()
    {
        await Task.Run(() => Symbols.Add(Enum.GetValues<Symbol>()));
    }

    public ObservableCollection<Symbol> Symbols { get; set; }
    private string _select = "";

    public string Select
    {
        get => _select;
        set
        {
            SetField(ref _select, value);
            Symbols.Clear();
            if (string.IsNullOrEmpty(value))
            {
                Symbols.Add(Enum.GetValues<Symbol>());
                return;
            }

            Symbols.Add(Enum.GetValues<Symbol>()
                .Where(x => x.ToString().Contains(value, StringComparison.OrdinalIgnoreCase)));
        }
    }
}